@isTest
private class PartsReturnDetailsControllerTest {
    static testMethod void testMethod1() {
        

        Product__c p1 = TestUtils.createProduct();
        p1.Brand__c = '迈克';
        p1.Category3__c = '配件';
        p1.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');
        p1.NCCode__c = '1101110000';
        p1.Category0__c = '配件';
        insert p1;


        PartsLendingApplication__c pla = new PartsLendingApplication__c();
        pla.IsSycToNc__c = true;
        pla.InventoryOrganization__c = 'MKSY';
        insert pla;

        PartsLendingDetails__c pld = new PartsLendingDetails__c();
        pld.Product__c = p1.Id;
        pld.No__c =5;
        pld.A_InvoiceNo__c = 1;
        pld.A_WarrantyNo__c =1;
        pld.B_No__c = 5;
        pld.PartsLendingApplication__c = pla.Id;
        insert pld;



        PageReference page2 = new PageReference('/apex/PartsReturnDetails');
        System.Test.setCurrentPage(page2);

        PartsReturnDetailsController pra = new PartsReturnDetailsController();
        pra.setNil();
        pra.init();
		pra.searchCompany = 'MKSY';
        pra.getSearch();


        Map<String,Object> saveMap =new Map<String,Object>();


        saveMap.put('company', 'MKSY');
        saveMap.put('datas', JSON.deserializeUntyped(EncodingUtil.urlDecode(pra.dataJson, 'UTF-8')));
        System.debug('PartsReturnDetailsControllerTest==>'+saveMap);

        pra.saveJson = EncodingUtil.urlEncode(JSON.serialize(saveMap), 'UTF-8');
        pra.save();


        PartsReturn__c pl = [select Id from PartsReturn__c limit 1];
		System.debug('PartsReturnDetailsControllerTest==>'+pl);

		PageReference page1 = new PageReference('/apex/PartsReturnDetails?id='+pl.Id);
        System.Test.setCurrentPage(page1);

        PartsReturnDetailsController pra1 = new PartsReturnDetailsController();
        pra1.init();



    }
}